package com.itcs.app.pay.swiftpass.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.itcs.app.pay.swiftpass.util.PaymentKit;
import com.itcs.app.util.HttpUtil;

/**
 * 威富通对账单下载测试
 * @author hanhengwang
 * @date 2018-03-26 14:00
 *
 */
@Controller
@RequestMapping("/swiftpass")
public class SwiftpassBillCheckController {

//	@RequestMapping("/billCheck")
	public static void billCheck() {
		String mch_id = "7551000001";
		String url = "https://download.swiftpass.cn/gateway";
		String bill_date = "20180323";
		
		Map<String, String> paraMap = new HashMap<>();
		paraMap.put("service", "pay.bill.merchant");
		paraMap.put("bill_date", bill_date);// 格式：yyyyMMdd(如：20150101)
		// ALL，返回支付成功和转入退款的订单，默认值.SUCCESS，返回支付成功的订单  REFUND，返回转入退款的订单
		paraMap.put("bill_type", "ALL");
		paraMap.put("mch_id", mch_id);
		paraMap.put("nonce_str", "ITC"+System.currentTimeMillis());
		
		paraMap.put("sign_type", "MD5");
		paraMap.put("version", "1.0.0");
		paraMap.put("charset", "UTF-8");
		String sign = PaymentKit.createSign(paraMap, "9d101c97133837e13dde2d32a5054abb");
		paraMap.put("sign", sign);
		String mapToXml = PaymentKit.mapToXml(paraMap);
		String result = HttpUtil.httpRequest(url, "POST", mapToXml);
		System.out.println(result);
	}
	
	public static void main(String[] args) {
		billCheck();
	}
	
}
